import java.awt.*;
import java.awt.event.MouseEvent;
import java.awt.geom.Ellipse2D;

public class DessinEllipse extends Dessin{
	private static final long serialVersionUID = 1L;

	int xDebut;
	int yDebut;
	Color defaultColor;
	Shape shape;
	
	public void setColor(Color c)
	{
		defaultColor = c;
		setBackground(defaultColor);
	}
	
	public boolean contains(int x, int y)
	{
		if(shape == null || ! shape.getBounds().getSize().equals(getSize()))
		{
			shape = new Ellipse2D.Float(0, 0, this.getWidth(), this.getHeight());
		}
		return shape.contains(x, y);
	}
	
	public void paint(Graphics g)
	{
		this.setOpaque(false);
		g.setColor(defaultColor);
		g.fillOval(0, 0, this.getWidth(), this.getHeight());
	}

	public void mouseDragged(MouseEvent e) {
		DessinEllipse.this.setBounds(DessinEllipse.this.getX() + (e.getX() - xDebut), DessinEllipse.this.getY() + (e.getY() - yDebut), DessinEllipse.this.getWidth(), DessinEllipse.this.getHeight());
		
		repaint();
	}
	public void mousePressed(MouseEvent e) {
		xDebut = e.getX();
		yDebut = e.getY();
	}
}
